#include "stm32f10x.h"                  // Device header
#include "KEY.h"
#include "LED.h"


int main(void)
{
    LED();  // 初始化 LED
    KEY();  // 初始化按键
    
    while(1)
    {
        uint8_t key = KEY_AN();  // 获取按键值
        
        if (key == 1)  // 按键1：切换 LED1
        {
            static uint8_t led1_state = 0;
            if (led1_state == 0)
            {
                LED1_ON();
                led1_state = 1;
            }
            else
            {
                LED1_OFF();
                led1_state = 0;
            }
        }
        else if (key == 2)  // 按键2：切换 LED2
        {
            static uint8_t led2_state = 0;
            if (led2_state == 0)
            {
                LED2_ON();
                led2_state = 1;
            }
            else
            {
                LED2_OFF();
                led2_state = 0;
            }
        }
    }
}
